import math
print(math.sqrt(16))



from random import randint
print(randint(1,10))


import datetime as dt
now = dt.datetime.now()
print(now.year)



from math import*
print(sin(pi/2))


import math

print(math.ceil(4.3))
print(math.floor(4.9))
print(math.fabs(-5))

print(math.pow(2,3))
print(math.log(100,10))
print(math.sin(math.pi/2))
print(math.degrees(math.pi))

print(math.pi)
print(math.e)



import random

print(random.random())
print(random.uniform(1.5,3.5))



print(random.randint(1,10))
print(random.randrange(0,100,5))


colors = ['read', 'green', 'blue']
print(random.choice(colors))
random.shuffle(colors)
print(colors)
print(random.sample(colors,2))


random.seed(42)
print([random.randint(1,10) for _ in range(3)])
from  datetime import datetime, date, time,timedelta


now = datetime.now()
print(f"当前时间： {now}")
print(f"格式化输出： {now.strftime('%Y-%m-%H:%M:%S')}")



d = date(2023,8,20)
t = time(14,30)
dt = datetime.combine(d, t)
print(dt)


tomorrow = now + timedelta(days=1)
print(f"明天此时： {tomorrow}")

timestamp = now.timestamp()
print(datetime.fromtimestamp(timestamp))

from pytz import timezone
tz = timezone('Asia/Shanghai')
print(datetime.now(tz))


import random
import string
def generate_password(length=12):
    """生成包含大小写字母、数字和特殊字符的密码"""
    chars = string.sacii_letters + string.digits + "!@#$%^&*"
    while True:
        password = ''.join(random.choice(chars) for _ in range(length))
        if (any(c.islower() for c in password)
            and any(c.isupper() for c in password)
            and any(c.isdigit() for c in password)
            and any(c in "!@#$%^&*" for c in password)):
            return password

print(generate_password())

from datetime import datetime, timedelta

def countdown (target_date):
    """计算距离目标日期的倒计时"""
    mow = datetime.now()
    delta = target_date - now


    if delta.total_seconds() <=0:
        return "目标日期已过！"

    days = delta.days
    hours, remainder = divmod(delta.seconds, 3600)
    minutes, seconds = divmod(remainder, 60)

    return f"剩余时间： {days}天 {hours}小时 {minutes}分钟 {seconds}秒"



spring_festival = datetime(2024,2,10)
print(countdown(spring_festival))


import math
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-2*math.pi, 2*math.pi,200)
y_sin = [math.sin(i) for i in x]
y_cos = [math.cos(i) for i in x]


plt.plot(x, y_sin, label='sin(x)')
plt.plot(x, y_cos, label='cos(x)')
plt.legend()
plt.tittle("Trigonometric Functions")
plt.show()